package org.zjh.controller.listener;

import org.zjh.view.ui.GameUi;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * @description: 退出游戏按钮监听
 * @author 郑佳豪
 * @date 2024/10/5 2:59
 * @version 1.0
 */
public class ExitGameLis extends MouseAdapter {


    @Override
    public void mouseClicked(MouseEvent e) {
        // 显示确认对话框
        int result = JOptionPane.showConfirmDialog(
                GameUi.gameMenuFrame.getGameMenuPanel(),
                "是否要退出游戏?",
                "退出游戏",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE
        );

        // 根据用户的选择执行操作
        if (result == JOptionPane.YES_OPTION) {
            // 用户点击了“是” 退出程序
            System.exit(0);
        }

    }

}
